package com.suoluo.zenapp.common.file;

import com.suoluo.zenapp.common.config.SystemConfigHolder;

public class FileEntry {

	private String filePreffix;

	private String fileName;

	public FileEntry(String filePreffix, String fileName) {
		super();
		this.filePreffix = filePreffix;
		this.fileName = fileName;
	}

	public FileEntry(String filePath) {
		int fileNameIndexStart = filePath.lastIndexOf("/");
		this.filePreffix = filePath.substring(0, fileNameIndexStart + 1);
		this.fileName = filePath.substring(fileNameIndexStart + 1);
	}

	public String getFilePreffix() {
		return filePreffix;
	}

	public void setFilePreffix(String filePreffix) {
		this.filePreffix = filePreffix;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	/**
	 * 获取原图的保存路径
	 * @return
	 */
	public String getFilePath() {
		return this.filePreffix + this.fileName;
	}
	/**
	 * 获取小图片的保存路径
	 * @return
	 */
	public String getMiniFilePath() {
		return this.filePreffix +SystemConfigHolder.getMiniImgPreffix()+ this.fileName;
	}
	/**
	 * 生成小图片路径
	 * 
	 * @param preffix
	 *            图片前缀
	 * @param miniPreffix
	 *            小图片前缀
	 * @param fileName
	 *            图片名称
	 * @return
	 */
	public static String getMiniFilePath(String preffix, String miniPreffix,
			String fileName) {
		return preffix + miniPreffix + fileName;
	}

}
